<template>
	<view>
		
		<template v-if="type == 1">	
			<view class="goods" :class="type == 2 ? 'yellow' : ''">	
				<view class="address">
					<view class="label">{{$t("公司名称")}}</view>
					<img :src="HTTP_IMG_UTL+'agencyIcon1.png'" class="headline_img" />
					<view>{{item[$t('item.company_name')] || $t("暂无信息") }}</view>
				</view>
				<view class="address">
					<view class="label">{{$t("公司所在地")}}</view>
					<img :src="HTTP_IMG_UTL+'location.png'" class="headline_img" />
					<!-- <view>{{item.companycitys[$t('item.city.mergename')] || $t("暂无信息") }}</view> -->
					<view>{{item.hyd || $t("暂无信息") }}</view>
				</view>
				<view class="address">
					<view class="label">{{$t("通关口岸")}}</view>
					<img :src="HTTP_IMG_UTL+'location1.png'" class="headline_img" />
					<!-- <view>{{item.portcitys[$t('item.city.mergename')] || $t("暂无信息") }}</view> -->
					<view>{{item.shd || $t("暂无信息") }}</view>
				</view>
				
				<view class="type">
					<TransportType :item="item"></TransportType>
					<FromToCountry :item="item"></FromToCountry>
				</view>
			</view>
		</template>
		
		
		<template v-if="type == 2">
			<view class="goods" :class="type == 2 ? 'yellow' : ''">
				<view class="flexImg">
					<template v-if="item.images && item.images.length > 0">
						<u-image width="300rpx" height="300rpx" :border-radius="20" :src="toImages(item.images[0])">
						</u-image>
					</template>
					<template v-else>
						<u-image width="300rpx" height="300rpx" :border-radius="20"></u-image>
					</template>
					<view class="imgFlex">
						<view class="label">
							{{item[$t('item.goods_name')]}}
						</view>
						<view  v-if="item[$t('item.brand')]" class="label">{{$t("品牌")}}</view>
						<view  v-if="item[$t('item.brand')]"  class="text underline">
							{{item[$t('item.brand')]}}
						</view>
						
						
						<FromToCountry :item="item" style="margin-top: 15rpx;"></FromToCountry>
						<view class="lineP">
							<Tag :text="item[$t('item.goods_weight')] + ' kg'" color="#008aff"></Tag>
							<Tag :text="item[$t('item.goods_volume')] + ' m³'" color="#ff7200"></Tag>
							<Tag :text="item[$t('item.goods_num')]+item[$t('item.number_unit')]" color="#18d62a"></Tag>
						</view>
						
					</view>
				</view>
				
				
				
				<view class="type">
					<TransportType :item="item"></TransportType>
				</view>
				
				
				
				<!--<view class="address">
					<view class="label">{{$t("货物所在地")}}</view>
					<img :src="HTTP_IMG_UTL+'agencyIcon3.png'" class="headline_img" />-->
					<!-- <view>{{item.departurecitys[$t('item.city.mergename')] || $t("暂无信息") }}</view> -->
					<!-- <view>{{item.hyd || $t("暂无信息") }}</view>-->
				<!--</view>-->
				
				<view class="address">
					<view class="label">{{$t("通关口岸")}}</view>
					<image :src="HTTP_IMG_UTL+'tubiao3.png'" class="headline_img" />
					<view>{{item.shd || $t("暂无信息") }}</view>
				</view>
				
				<view class="address" v-if="item.hwcfd">
					<view class="label">{{$t("出发城市")}}</view>
					<image :src="HTTP_IMG_UTL+'tubiao1.png'" class="headline_img" />
					<view>{{item.hwcfd || $t("暂无信息") }}</view>
				</view>
				
				<view class="address" v-if="item.hwddd">
					<view class="label">{{$t("到达城市")}}</view>
					<image :src="HTTP_IMG_UTL+'tubiao2.png'" class="headline_img" />
					<view>{{item.hwddd || $t("暂无信息") }}</view>
				</view>
				
				<!-- <view class="address"  v-if="item.reachcitys&&item.reachcitys.mergename">
					<img :src="HTTP_IMG_UTL+'transportIcon1.png'" class="headline_img" />
					<view class="label">{{ $t('货物到达地') }}</view>
					<view v-if="lang=='zh'">{{item.reachcitys.mergename || $t("暂无信息") }}</view>
					<view v-if="lang!='zh'">{{item.reachcitys.mergename_ru || $t("暂无信息") }}</view>
				</view> -->
			</view>
		</template>

		<view class="goods" :class="type == 2 ? 'yellow' : ''">
			<view :class="type == 2 ? 'yellow' : ''">
				<span style="color:darkorange ; margin-right: 5px;">|</span> 
				<text v-if="type === 1">{{$t('提供服务')}}</text>
				<text v-if="type === 2">{{$t('所需服务')}}</text>
			</view>
			<Server :item="item"></Server>
		</view>

		<view class="goods" :class="type == 2 ? 'yellow' : ''" v-if="type == 2">
			<ProductWHL :item="item" :type="type"></ProductWHL>
		</view>
		
	</view>
</template>

<script>
	import TransportType from '@/components/TransportType.vue'
	import FromToCountry from '@/components/FromToCountry.vue'
	import Tag from '@/components/Tag.vue'
	import ProductWHL from '@/components/ProductWHL.vue'
	import myTitle from "@/components/myTitle.vue";
	import Server from './Crossborder/Server.vue'
	import {
		ImageUrl,
		isBase64
	} from "@/common/public";
	import {
		IMAGE_URL,
		HTTP_IMG_UTL
	} from '@/config/app'
	export default {
		props: {
			item: {
				type: Object,
				default: {},
			},
			type: {
				type: String | Number,
				default: '1',
			},
		},
		data() {
			return {
				HTTP_IMG_UTL,
				lang:getApp().globalData.lang
			}
		},
		components: {
			Tag,
			TransportType,
			FromToCountry,
			myTitle,
			Server,
			ProductWHL
		},
		computed: {
			toImages() {
				return (src) => {
					return isBase64(src) ? src : IMAGE_URL + src
				}
			},
			storeImages() {
				return (sum, images) => [images[0]]
			},
		},
		methods: {
			ImageUrl,
		}
	}
</script>

<style lang="scss" scoped>
	.goods {
		width: 90%;
		box-shadow: 0 0 10px #ddd;
		border-radius: 10px;
		padding: 10px 12px;
		margin: 0 auto;
		margin-bottom: 20rpx;
		font-size: 30rpx;

		&.yellow {
			background: #fefcf6;
		}

		.underline {
			border-bottom: 1rpx solid #ccc;
			padding-bottom: 10rpx;
		}

		.label {
			font-weight: 800;
			margin-bottom: 10rpx;
		}

		.text {
			color: #666;
			margin-top: 15rpx;
		}

		.lineP {
			margin: 20rpx 0 30rpx 0;
		}

		.flexImg {
			display: flex;
			align-items: stretch;
			flex-direction: row;
			justify-content: space-evenly;

			.imgFlex {
				flex: 1;
				margin-left: 10px;
				display: flex;
				flex-direction: column;
			}
		}

		.type {
			display: flex;
			justify-content: space-between;
			align-items: flex-end;
			padding-left: 10rpx;
			margin-top: 20rpx;
			margin-bottom: 20rpx;
			// padding-right: 22rpx;
			// width: 90%;
			// margin: 0 auto;
		}

		.address {
			margin-bottom: 32rpx;
			font-size: 30rpx;
			position: relative;
			padding-left: 45rpx;
			// font-weight: 600;

			// .warp {
			// 	width: 55%;
			// }

			.headline_img {
				position: absolute;
				left: 0;
				top: 4rpx;
				width: 30rpx;
				height: 30rpx;
			}

			.label {
				font-weight: 600;
				margin-bottom: 10rpx;
			}
		}
	}
</style>